package priv.tuyou.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import priv.tuyou.bo.AppData;
import priv.tuyou.constants.WebContext;
import priv.tuyou.system.po.Article;

/**
 * 文件上传的控制器
 * @author：涂有
 * @date 2017年1月2日 下午11:37:42
 */
@Controller
@RequestMapping("/upload")
public class UploadController {

	/**
	 * 图片上传
	 */
	@RequestMapping(value="image", method=RequestMethod.POST)
	@ResponseBody
	public AppData imageUpload(@RequestParam(value = "file", required = false) CommonsMultipartFile file){
		
		WebContext.storeFile(file, Article.class);
		return new AppData(1, "上传成功");
	}
}
